<template>
	<view class="store-home" :style="{ 'background-image': `url(../../../static/images/shop_top_bg.png)` }">
		<view :style="{ height: `${systemInfo.statusBarHeight}px` }"></view>
		<scroll-view class="main" scroll-y="true" @scroll="scrollHome" @scrolltolower="getAllGoods()">
			<view class="swiper">
				<u-swiper :list="slideshowlist" height="320"></u-swiper>
			</view>

			<view class="" style="background-color: #f6f6f6;border-radius: 30rpx; 30rpx 0 0">
				<!-- 优选好货 -->
				<view id="guarantee" class="boutique">
					<view class="tetle">
						<view class="line"></view>
						优选好货
					</view>
					<view class="list">
						<view class="left" @click="goGoodsDetail(storeinfo.optimal[0])">
							<view class="tetle">
								{{storeinfo.optimal[0].store_name}}
							</view>
							<view class="price">
								{{storeinfo.optimal[0].price}}
							</view>
							<image class="img" :src="storeinfo.optimal[0].image" mode=""></image>
						</view>
						<view class="right">
							<view class="top" @click="goGoodsDetail(storeinfo.optimal[1])">
								<view class="telte">
									{{storeinfo.optimal[1].store_name}}
								</view>
								<view class="price-img">
									<view class="price">
										{{storeinfo.optimal[1].price}}
									</view>
									<image class="img" :src="storeinfo.optimal[1].image" mode=""></image>
								</view>
							</view>
							<view class="bottom" @click="goGoodsDetail(storeinfo.optimal[2])">
								<view class="telte">
									{{storeinfo.optimal[2].store_name}}
								</view>
								<view class="price-img">
									<view class="price">
										{{storeinfo.optimal[2].price}}
									</view>
									<image class="img" :src="storeinfo.optimal[2].image" mode=""></image>
								</view>
							</view>
						</view>
					</view>
				</view>

				<!-- 推荐 -->
				<view class="recommend">
					<view class="tetle">
						<view class="line"></view>
						热卖推荐
					</view>
					<scroll-view class="list" :scroll-x="true">
						<view class="item" v-for="(item, index) in storeinfo.recommend" :key="index"
							@click="goGoodsDetail(item)">
							<image class="img" :src="item.image" mode=""></image>
							<view class="name">
								{{item.store_name}}
							</view>
							<view class="price">
								{{item.price}}
							</view>
						</view>
					</scroll-view>
				</view>

				<!-- 店铺栏 -->
				<view class="store">
					<image style="background-color: #FFFFFF;" :src="storeinfo.mer_avatar"></image>
					<view class="text">
						<text class="name">{{ storeinfo.mer_name }}</text>
						<view class="score">
							<u-rate :disabled="true" size="24" :count="count" v-model="storeinfo.product_score">
							</u-rate>
							<span
								style="padding-left: 10rpx; font-size: 26rpx;color: #000000;">{{ storeinfo.product_score }}</span>
						</view>
					</view>
					<view class="goodssum">
						<view class="sum">{{ storeinfo.totalProduct }}</view>
						<view class="ww">全部商品</view>
					</view>
				</view>
				<view class="" style="height: 20rpx;background-color: #f6f6f6;">
				</view>
				<!-- 商品 -->
				<view class="goods-wrap">
					<view class="tetle">
						<view class="line"></view>
						热卖推荐
					</view>
					<view v-if="allgoods.length" :class="{ column: isColumn }" class="goods">
						<view v-for="item in allgoods" :key="item.product_id" class="item"
							@click="goGoodsDetail(item)">
							<view class="image">
								<image :src="item.image"></image>
							</view>
							<view class="text">
								<view class="name">{{ item.store_name }}</view>
								<view class="money-wrap">
									<view class="label">
										<view class="ticket" v-if="item.issetCoupon">{{ i18n.Get }}</view>
										<view class="ticket">{{ i18n.Importedgoods }}</view>
										<view class="ticket">{{ i18n.Crossborderdirect }}</view>
										<view class="pinkage">{{ i18n.Pinkage }}</view>
									</view>
									<view class="money">
										¥
										<text>{{ item.price }}</text>
									</view>
								</view>
								<view class="score">{{ item.rate }}{{ i18n.Score }}
									{{ item.reply_count }}{{ i18n.Comments }}
								</view>
							</view>
							<view v-if="item.max_extension" class="foot">
								<text v-show="!isColumn" class="iconfont"></text>
								{{ i18n.Earn }} ¥{{ item.max_extension }}
							</view>
						</view>
					</view>
				</view>
				<view
					style="text-align: center; margin-bottom: 10rpx; font-size: 24rpx;height: 60rpx;line-height: 60rpx;">
					{{ loadTitle }}
				</view>
			</view>
		</scroll-view>
	</view>
</template>
<script>
	import {
		mapGetters
	} from 'vuex';
	const globalData = getApp().globalData;
	export default {
		props: {
			slideshowlist: '', //轮播列表
			storeinfo: '',
			allgoods: '',
			loadTitle: '',
			isColumn: true,

		},
		data() {
			return {
				storeHeight: '',
				mer_id: globalData.mer_id,
				count: 5,
			};
		},
		computed: {
			i18n() {
				return globalData.$t('home');
			},
			...mapGetters(['isLogin'])
		},
		created: function() {},
		methods: {
			//获得全部商品
			getAllGoods: function() {
				this.$emit("getAllGoods", this.getAllGoods);
			},
			//去详情页
			goGoodsDetail: function(val) {
				this.$emit('goGoodsDetail', val);
			},
			// 商铺首页滚动 navbar 吸顶
			scrollHome: function(e) {
				this.$emit('scrollHome', e.detail.scrollTop >= this.storeHeight);
			}
		},
		mounted: function() {
			const query = uni.createSelectorQuery().in(this);
			query
				.select('#guarantee')
				.boundingClientRect(data => {
					this.storeHeight = data.top;
				})
				.exec();
		},
	};
</script>
<style lang="scss">
	.float {
		z-index: 999;
		position: fixed;
		right: 30rpx;
		bottom: 150rpx;

		image {
			width: 80rpx;
			height: 80rpx;
		}
	}

	.store-home {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		display: flex;
		flex-direction: column;
		background: left top/750rpx 287rpx no-repeat fixed;
		overflow: hidden;

		.boutique {
			margin: 0 30rpx 30rpx;
			background-color: #FFFFFF;
			border-radius: 20rpx;
			padding: 24rpx;

			.tetle {
				font-size: 34rpx;
				font-weight: bold;
				display: flex;
				align-items: center;

				.line {
					display: inline-block;
					width: 6rpx;
					height: 34rpx;
					background: #fd342a;
					border-radius: 3px;
					margin-right: 16rpx;
				}
			}

			.list {
				padding-top: 30rpx;
				display: flex;
				justify-content: space-between;
				width: 100%;
				overflow: hidden;

				.left {
					padding-right: 24rpx;
					border-right: 2rpx solid #EAEAEA;
					overflow: hidden;

					.tetle {
						font-size: 26rpx;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}

					.price {
						font-weight: bold;
						font-size: 26rpx;
						color: #DB4234;
						padding: 16rpx 0 52rpx;
					}

					.price::before {
						content: '￥';
						font-size: 20rpx;
					}

					.img {
						width: 297rpx;
						height: 297rpx;
						border-radius: 8rpx;
					}
				}

				.right {
					display: flex;
					flex-direction: column;
					overflow: hidden;
					width: 100%;

					.top {
						border-bottom: 2rpx solid #EAEAEA;
					}

					.bottom {
						padding-top: 24rpx;
					}

					.top,
					.bottom {
						padding-left: 24rpx;
						flex: 1;

						.telte {
							font-size: 26rpx;
							font-weight: bold;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							padding-bottom: 16rpx;
						}

						.price-img {
							display: flex;
							justify-content: space-between;

							.price {
								font-weight: bold;
								font-size: 26rpx;
								color: #DB4234;
								padding: 16rpx 0 52rpx;
							}

							.price::before {
								content: '￥';
								font-size: 20rpx;
							}

							.img {
								width: 144rpx;
								height: 144rpx;
								border-radius: 8rpx;
							}
						}
					}
				}
			}
		}

		.recommend {
			margin: 0 30rpx 30rpx;
			background-color: #FFFFFF;
			border-radius: 20rpx;
			padding: 24rpx;

			.tetle {
				font-size: 34rpx;
				font-weight: bold;
				display: flex;
				align-items: center;

				.line {
					display: inline-block;
					width: 6rpx;
					height: 34rpx;
					background: #fd342a;
					border-radius: 3px;
					margin-right: 16rpx;
				}
			}

			.list {
				padding-top: 30rpx;
				white-space: nowrap;
				overflow: hidden;

				.item {
					display: inline-block;
					margin-right: 16rpx;
					width: 194rpx;
					text-align: center;

					.img {
						width: 194rpx;
						height: 194rpx;
					}

					.name {
						width: 100%;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
						font-size: 26rpx;
						font-weight: bold;
					}

					.price {
						font-size: 28rpx;
						font-weight: bold;
						color: #DB4234;
					}

					.price::before {
						content: '￥';
						font-size: 24rpx;
					}
				}

			}
		}

		.search {
			margin: 12rpx 120rpx 0 20rpx;
		}

		.store {
			background-color: #ffffff;
			position: relative;
			z-index: 6;
			display: flex;
			align-items: center;
			padding: 20rpx;
			height: 136rpx;
			border-radius: 20rpx;
			margin: 24rpx 30rpx;

			image {
				width: 74rpx;
				height: 74rpx;
				border-radius: 6rpx;
				margin-right: 20rpx;
			}

			.text {
				display: flex;
				flex-direction: column;
				flex: 1;
				min-width: 0;
				margin-right: 20rpx;

				.name {
					flex: 1;
					min-width: 0;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					font-weight: bold;
					font-size: 32rpx;
					line-height: 1;
					color: #000;
				}

				.score {
					display: flex;
					align-items: center;
					margin-top: 17rpx;
					font-weight: 400;
					font-size: 24rpx;
					line-height: 1;
					color: #ffffff;
				}
			}

			.goodssum {
				display: flex;
				flex-direction: column;
				justify-content: center;

				.sum {
					text-align: center;
					font-size: 32rox;
					font-weight: bold;
					color: #000000;
				}

				.ww {
					font-size: 20rpx;
					color: #999999;
				}
			}
		}

		.main {
			flex: 1;
			min-height: 0rpx;
		}

		.swiper {
			margin: 110rpx 30rpx 30rpx;
		}

		.goods-wrap {
			.tetle {
				border-radius: 20rpx 20rpx 0 0;
				padding: 24rpx;
				margin: 0 24rpx;
				font-size: 34rpx;
				font-weight: bold;
				display: flex;
				align-items: center;
				background-color: #FFFFFF;

				.line {
					display: inline-block;
					width: 6rpx;
					height: 34rpx;
					background: #fd342a;
					border-radius: 3px;
					margin-right: 16rpx;
				}
			}
		}

		.goods {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			padding-top: 20rpx;
			padding-right: 20rpx;
			padding-left: 20rpx;
			background-color: #f5f5f5;
			width: 750rpx;

			.item {
				width: 345rpx;
				border-radius: 16rpx;
				margin-bottom: 20rpx;
				background-color: #ffffff;
				overflow: hidden;

				.image {
					width: 345rpx;
					height: 345rpx;

					image {
						display: block;
						width: 100%;
						height: 100%;
					}
				}

				.text {
					padding: 20rpx 20rpx 25rpx;

					.name {
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
						font-weight: 500;
						font-size: 30rpx;
						color: #222222;
					}

					.money-wrap {
						margin-top: 20rpx;

						.money {
							font-weight: bold;
							font-size: 26rpx;
							color: #e93323;

							text {
								font-size: 34rpx;
								line-height: 1;
							}
						}

						.label {
							display: flex;
							flex-wrap: wrap;

							.ticket {
								height: 26rpx;
								padding-right: 9rpx;
								padding-left: 9rpx;
								border: 1rpx solid #e93323;
								border-radius: 4rpx;
								margin-left: 10rpx;
								font-weight: 500;
								font-size: 20rpx;
								line-height: 24rpx;
								color: #e93323;
								margin-top: 17rpx;
							}

							.pinkage {
								height: 26rpx;
								padding-right: 9rpx;
								padding-left: 9rpx;
								border: 1px solid #6b78ab;
								border-radius: 4rpx;
								margin-left: 10rpx;
								font-weight: 500;
								font-size: 20rpx;
								line-height: 24rpx;
								color: #6b78ab;
								margin-top: 17rpx;
							}
						}
					}

					.score {
						margin-top: 20rpx;
						font-weight: 500;
						font-size: 20rpx;
						line-height: 1;
						color: #737373;
					}
				}

				.foot {
					display: flex;
					justify-content: center;
					align-items: center;
					height: 52rpx;
					background: linear-gradient(to right, #f11b09, #f67a38);
					font-weight: 500;
					font-size: 24rpx;
					color: #ffffff;

					.iconfont {
						margin-right: 10rpx;
						font-size: 22rpx;
						line-height: 1;
					}
				}
			}
		}

		.column {
			padding: 0;

			.item {
				position: relative;
				display: flex;
				align-items: center;
				width: 100%;
				padding: 30rpx 20rpx;
				border-radius: 0;
				margin: 0rpx 24rpx 24rpx;
				border-radius: 20rpx;

				&::before {
					content: ' ';
					position: absolute;
					top: 0;
					right: 20rpx;
					left: 250rpx;
				}

				.image {
					width: 200rpx;
					height: 200rpx;
					border-radius: 16rpx;
					overflow: hidden;
				}

				.text {
					position: relative;
					flex: 1;
					min-width: 0;
					padding-top: 0;
					padding-right: 0;
					padding-bottom: 0;

					.name {
						white-space: pre-wrap;
						text-overflow: -o-ellipsis-lastline;
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp: 2;
						-webkit-box-orient: vertical;
						color: #282828;
					}

					.score {
						margin-top: 5rpx;
					}

					.money-wrap {
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						margin-top: 0rpx;
						.money{
							margin: 10rpx 0;
						}
						.label {
							margin-bottom: 8rpx;
						}

						.ticket {
							height: 28rpx;
							padding-right: 12rpx;
							padding-left: 12rpx;
							border: none;
							border-radius: 0;
							margin-top: 17rpx;
							margin-left: 0;
							background: url(@/static/images/yh.png) top left/100% 100% no-repeat;
							line-height: 28rpx;
						}

						.pinkage {
							height: 26rpx;
							padding-right: 9rpx;
							padding-left: 9rpx;
							border: 1px solid #6b78ab;
							border-radius: 4rpx;
							margin-left: 10rpx;
							margin-top: 17rpx;
							font-weight: 500;
							font-size: 20rpx;
							line-height: 24rpx;
							color: #6b78ab;
						}
					}
				}

				.foot {
					position: absolute;
					right: 20rpx;
					bottom: 30rpx;
					height: 44rpx;
					padding-right: 17rpx;
					padding-left: 17rpx;
					border-radius: 22rpx;
					font-size: 22rpx;
					color: #f5f5f5;
				}
			}

			.item:first-child {
				border-radius: 0 0 20rpx 20rpx;
			}
		}
	}
</style>
